package com.db.williamchart.renderer.executor;

import com.db.williamchart.data.Frame;
import ohos.utils.Pair;

import java.util.ArrayList;
import java.util.List;

public class DefineHorizontalBarsClickableFrames {

    public List<Frame> invoke(Frame innerFrame, List<Pair<Float,Float>> datapointsCoordinates){
        float halfDistanceBetweenDataPoints = (innerFrame.getBottom() - innerFrame.getTop() - (datapointsCoordinates.size() + 1)) /
                datapointsCoordinates.size() / 2;
        List<Frame> frames = new ArrayList<>();
        for (Pair<Float,Float> pair : datapointsCoordinates){
            frames.add(new Frame(innerFrame.getLeft(),
                    pair.s - halfDistanceBetweenDataPoints,
                    innerFrame.getRight(),
                    pair.s + halfDistanceBetweenDataPoints));
        }
        return frames;
    }
}
